package org.budo.cmbc.sdk.entity;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.budo.xml.XmlObject;

/**
 * @author lmw
 */
@Getter
@Setter
@Slf4j
public class XferResponse extends AbstractCmbcResponse {
    private static final long serialVersionUID = 8755561348099847272L;

    private String trnId;

    private String svrId;

    private String insId;

    private String balance;

    public XferResponse(String responseXml) {
        this.setResponseBody(responseXml);

        XmlObject xDataBody = this.xDataBody(responseXml);
        if (null == xDataBody) {
            log.error("#31 xDataBody=" + xDataBody + ", responseXml=" + responseXml);
            return;
        }

        XmlObject transfer = xDataBody.getChildNodeByName("transfer");
        this.setTrnId(transfer.getChildNodeTextContentByName("trnId"));
        this.setSvrId(transfer.getChildNodeTextContentByName("svrId"));
        this.setInsId(transfer.getChildNodeTextContentByName("insId"));

        this.setBalance(transfer.getChildNodeTextContentByName("balance"));
    }
}
